/**
 * pool:池
 * bushaofeng. 2012.1.13
 */

#ifndef __BS_POOL_H_
#define __BS_POOL_H_

#include "bs_type.h"
#include "bs_error.h"

#ifdef __cplusplus
extern "C"{
#endif

typedef struct bs_pool_t        bs_pool_t;
typedef struct _pool_head_t     _pool_head_t;

struct _pool_head_t{
    _pool_head_t*       prev;
    _pool_head_t*       next;
};

struct bs_pool_t{
    void*       mem;
    size_t      mem_size;
    size_t      size;
    size_t      esize;
    size_t      len;

    _pool_head_t*       unused;
};

bs_pool_t* bs_pool_create(size_t size, size_t esize);
int bs_pool_init(bs_pool_t* pool);
void* bs_pool_malloc(bs_pool_t* pool);
void bs_pool_free(void* mem);
int bs_pool_destroy(bs_pool_t* pool);

#ifdef __cplusplus
}
#endif
#endif
